package com.ruoyi.project.mobile;

import com.aliyuncs.exceptions.ClientException;
import com.ruoyi.common.utils.Sendmss;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.member.domain.Member;
import com.ruoyi.project.system.member.service.IMemberService;
import com.ruoyi.project.system.smsnotice.domain.SmsNotice;
import com.ruoyi.project.system.smsnotice.service.ISmsNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/test")
public class TestAController {


    @Autowired
    private IMemberService memberService;
    @Autowired
    private ISmsNoticeService smsNoticeService;


    @RequestMapping("/aaaaaa")
    public String aaa(){
        memberService.insertMember(new Member());
        return "a";
    }

    /**
     * 获取短信通知手机号
     */
    @GetMapping("/getSmsNotice")
    public AjaxResult getSmsNotice(@RequestParam String uid) {
        SmsNotice smsNotice =this.smsNoticeService.findAll();
        Member member = this.memberService.selectMemberById(uid);

        Sendmss s = new Sendmss();
            String phone = smsNotice.getPhone();
            String consignee = member.getUsername();
            String number = member.getMobile();
            try {
                s.sendSms(phone, number);
            } catch (ClientException e) {
                System.out.println(e.getMessage());
                e.printStackTrace();
            }
        return AjaxResult.success();
    }
}
